;; -*- coding: utf-8 -*-
;;----------------------------------------------------------------------------
;; Misc config - yet to be placed in separate files
;;----------------------------------------------------------------------------

(fset 'yes-or-no-p 'y-or-n-p)
(add-hook 'find-file-hooks 'goto-address-prog-mode)
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
(setq goto-address-mail-face 'link)

(setq make-backup-files nil)
(setq auto-save-default nil)

(setq-default regex-tool-backend 'perl)

(setq indent-tabs-mode nil)
(setq tab-width 4)
(setq c-basic-offset 4)

(setq default-major-mode 'text-mode)

;;Ctrl 窗口切换
(windmove-default-keybindings 'ctrl)

;;many windows
(setq gdb-many-windows t)

;;显示行列号
(setq line-number-mode t)
(setq column-number-mode t)
(global-linum-mode t)

;; 关闭烦人的出错时的提示声
(setq visible-bell t)

;; 关闭emacs启动时的画面
(setq inhibit-startup-message t)

;;光标靠近鼠标的时候，让鼠标自动让开，别挡住视线
(setq mouse-avoidance-mode 'animate)

;;括号匹配时显示另外一边的括号，而不是跳到另一个括号
(show-paren-mode t)
(setq show-paren-style 'parentheses)

(cua-mode t)

;; 自动的在文件末增加一新行
(setq require-final-newline t)

;; 当光标在行尾上下移动的时候，始终保持在行尾。
(setq track-eol t)

;; Copy whole line
;; ‘M-w’ copies the current line when the region is not active, and
;; ‘C-w’ deletes it.
(defadvice kill-ring-save (before slick-copy activate compile)
  "When called interactively with no active region, copy the current line."
  (interactive
   (if mark-active
       (list (region-beginning) (region-end))
     (progn
       (message "Current line is copied.")
       (list (line-beginning-position) (line-beginning-position 2))))))

(defadvice kill-region (before slick-copy activate compile)
  "When called interactively with no active region, cut the current line."
  (interactive
   (if mark-active
       (list (region-beginning) (region-end))
     (progn
       (list (line-beginning-position) (line-beginning-position 2))))))

(provide 'init-misc)
